package com.dawn.login.serviceimpl;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dawn.login.dao.LoginDao;
import com.dawn.login.service.LoginService;
import com.dawn.usermanage.bean.UserBean;
import com.dawn.utils.exceptions.DaoAccessException;

@Service
public class LoginServiceImpl implements LoginService{
    
    private static Logger logger = Logger.getLogger(LoginServiceImpl.class);

    @Autowired
    private LoginDao loginDAO;

    @Override
    public UserBean findUser(String username, String password){
        List<UserBean> users = null;
        try {
            users = loginDAO.findUser(username, password);
            if (!users.isEmpty()) {
                UserBean user = users.get(0);
                return user;
            }
        } catch (Exception e) {
            logger.error("Data access error!");
            e.printStackTrace();
            throw new DaoAccessException();
        }
        return null;
    }

    @Override
    public boolean updateUserSinaInfo(String sinaId) {
        return false;
    }

}
